/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Thuan
 */
@Entity
@Table(name = "AssignmentOfBatch")
@NamedQueries({
    @NamedQuery(name = "AssignmentOfBatch.findAll", query = "SELECT a FROM AssignmentOfBatch a"),
    @NamedQuery(name = "AssignmentOfBatch.findByAssignmentId", query = "SELECT a FROM AssignmentOfBatch a WHERE a.assignmentOfBatchPK.assignmentId = :assignmentId"),
    @NamedQuery(name = "AssignmentOfBatch.findByBatchId", query = "SELECT a FROM AssignmentOfBatch a WHERE a.assignmentOfBatchPK.batchId = :batchId"),
    @NamedQuery(name = "AssignmentOfBatch.findByFromDate", query = "SELECT a FROM AssignmentOfBatch a WHERE a.fromDate = :fromDate"),
    @NamedQuery(name = "AssignmentOfBatch.findByToDate", query = "SELECT a FROM AssignmentOfBatch a WHERE a.toDate = :toDate"),
    @NamedQuery(name = "AssignmentOfBatch.findByDescription", query = "SELECT a FROM AssignmentOfBatch a WHERE a.description = :description")})
public class AssignmentOfBatch implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AssignmentOfBatchPK assignmentOfBatchPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fromDate")
    @Temporal(TemporalType.DATE)
    private Date fromDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "toDate")
    @Temporal(TemporalType.DATE)
    private Date toDate;
    @Size(max = 2147483647)
    @Column(name = "description")
    private String description;
    @JoinColumn(name = "batchId", referencedColumnName = "batchId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Batch batch;
    @JoinColumn(name = "assignmentId", referencedColumnName = "assignmentId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Assignment assignment;

    public AssignmentOfBatch() {
    }

    public AssignmentOfBatch(AssignmentOfBatchPK assignmentOfBatchPK) {
        this.assignmentOfBatchPK = assignmentOfBatchPK;
    }

    public AssignmentOfBatch(AssignmentOfBatchPK assignmentOfBatchPK, Date fromDate, Date toDate) {
        this.assignmentOfBatchPK = assignmentOfBatchPK;
        this.fromDate = fromDate;
        this.toDate = toDate;
    }

    public AssignmentOfBatch(int assignmentId, int batchId) {
        this.assignmentOfBatchPK = new AssignmentOfBatchPK(assignmentId, batchId);
    }

    public AssignmentOfBatchPK getAssignmentOfBatchPK() {
        return assignmentOfBatchPK;
    }

    public void setAssignmentOfBatchPK(AssignmentOfBatchPK assignmentOfBatchPK) {
        this.assignmentOfBatchPK = assignmentOfBatchPK;
    }

    public Date getFromDate() {
        return fromDate;
    }

    public void setFromDate(Date fromDate) {
        this.fromDate = fromDate;
    }

    public Date getToDate() {
        return toDate;
    }

    public void setToDate(Date toDate) {
        this.toDate = toDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Batch getBatch() {
        return batch;
    }

    public void setBatch(Batch batch) {
        this.batch = batch;
    }

    public Assignment getAssignment() {
        return assignment;
    }

    public void setAssignment(Assignment assignment) {
        this.assignment = assignment;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (assignmentOfBatchPK != null ? assignmentOfBatchPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AssignmentOfBatch)) {
            return false;
        }
        AssignmentOfBatch other = (AssignmentOfBatch) object;
        if ((this.assignmentOfBatchPK == null && other.assignmentOfBatchPK != null) || (this.assignmentOfBatchPK != null && !this.assignmentOfBatchPK.equals(other.assignmentOfBatchPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.app.model.AssignmentOfBatch[ assignmentOfBatchPK=" + assignmentOfBatchPK + " ]";
    }

}
